# 创建一个只包含指定键的新字典，初始值设为 None
new_dict = dict.fromkeys(['key1', 'key2', 'key3'])
print(new_dict)  # {'key1': None, 'key2': None, 'key3': None}[^1]

# 如果你想自定义初始值，可以传递第二个参数
custom_value = 0
filled_dict = dict.fromkeys(['key1', 'key2', 'key3'], custom_value)
print(filled_dict)  # {'key1': 0, 'key2': 0, 'key3': 0}